package com.anlogic.sdk.utils.options;

import java.util.LinkedHashMap;
import java.util.Map;

public enum OsType {
	Standalone("standalone", "standalone"), FreeRTOS("freertos", "standalone"), RTTHREAD("rtthread", "rtthread"), RTTHREAD_NANO("rtthread_nano", "rtthread_nano"), Linux("linux", "linux");

	private String id;
	
	private String name;

	private static Map<String, OsType> idMap = new LinkedHashMap<>();

	private static Map<String, OsType> nameMap = new LinkedHashMap<>();

	static {
		for (OsType value : OsType.values()) {
			idMap.put(value.getId(), value);
			nameMap.put(value.getName(), value);
		}
	}

	OsType(String id, String name) {
		this.id = id;
		this.name = name;
	}

	public String getId() {
		return this.id;
	}

	public String getName() {
		return this.name;
	}

	public static String[] getIds() {
		return idMap.keySet().toArray(new String[0]);
	}

	public static String[] getNames() {
		return nameMap.keySet().toArray(new String[0]);
	}

	public static OsType getTypeById(String id) {
		return idMap.get(id);
	}

	public static OsType getTypeByName(String name) {
		return nameMap.get(name);
	}
	
	public static boolean isStandalone(String name) {
		return name != null && !name.isEmpty() && name.toLowerCase().equals(Standalone.getName().toLowerCase());
	}
	
	public static boolean isFreeRTOS(String name) {
		return name != null && !name.isEmpty() && name.toLowerCase().equals(FreeRTOS.getName().toLowerCase());
	}
	
	public static boolean isRtthread(String name) {
		return name != null && !name.isEmpty() && name.toLowerCase().equals(RTTHREAD.getName().toLowerCase());
	}
	
	public static boolean isRtthreadNano(String name) {
		return name != null && !name.isEmpty() && name.toLowerCase().equals(RTTHREAD_NANO.getName().toLowerCase());
	}
	
	public static boolean isLinux(String name) {
		return name != null && !name.isEmpty() && name.toLowerCase().equals(Linux.getName().toLowerCase());
	}
}